<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
    <div id="my-time"></div>
    <div id="play"></div>
  </body>

  <script>
      function time() {
          var d = new Date();//时间对象一定要放在内部，才能实现实时刷新
          var dt = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + "  " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
          document.getElementById("my-time").innerHTML = dt;
      }

      setInterval("time()", 100);

      //再此怎加不同的时间段播放不同的音乐
      function playM() {
          var d = new Date();
          document.getElementById("play").innerHTML = "<audio autoplay><source src=\"../img/" + (d.getMinutes() % 2 + 1) + ".mp3\" ></source></audio>";
      }

      setInterval(playM, 10000);
  </script>
</html>
